<?php

namespace app\web\validate;

use think\Validate;

class Login extends Validate
{
    protected $rule = [
        'code' => 'require',
        'nickname' => 'require',
        'avatar' => 'require',
        'sex' => 'require|number|between:0,2',
        'token' => 'require',
        'mobile' => 'require|mobile',
    ];

    protected $message = [
        'code.require' => 'code参数必填',
        'nickname.require' => 'nickname昵称参数必填',
        'avatar.require' => 'avatar头像参数必填',
        'sex.require' => 'sex性别参数必填',
        'sex.number' => 'sex性别参数为数字',
        'sex.between' => 'sex性别参数为1男，2女',
        'token.require' => '请求token参数必填',
        'mobile.require' => 'mobile参数必填',
        'mobile.mobile' => '手机号格式错误',
    ];

    //验证场景
    protected $scene = [
        'login' => ['code', 'nickname', 'avatar', 'sex'],
        'bind' => ['token', 'mobile'],
    ];
}
